import {reqGetSearchInfo} from "../network/home";

const state = {
  searchList: {}
};
const mutations = {
  GETSEARCHLIST(state, searchList) {
    state.searchList = searchList
  }

};
const actions = {
  //获取search模块数据
  async getSearchList(context, params={}) {
    //reqGetSearchInfo 至少传递一个参数 空对象
    //params形参： 是当用户派发actions的时候， 第二个参数传递过来的, 至少是一个空对象
    let result = await reqGetSearchInfo(params)
    if(result.code === 200) {
      context.commit('GETSEARCHLIST', result.data)
    }
  }
};
const getters = {
  attrsList(state) {
    return  state.searchList.attrsList || [];
  },
  goodsList(state) {
    return  state.searchList.goodsList || [];
  },
  trademarkList(state) {
    return  state.searchList.trademarkList || [];
  },

};

export default {
  state,
  actions,
  mutations,
  getters
}